<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>工地试验室</title>
<script type="text/javascript"
	src="<c:url value='/ext/ui/jquery-ui-1.8.12.custom.min.js'/>"></script>
<link href="${ctx}/styles/lightness/jquery-ui-1.8.12.custom.css"
	rel="stylesheet" />
<script type='text/javascript'
	src='${ctx}/scripts/plugin/jquery.liveSearch.js'></script>
<script type="text/javascript">
$(document).ready(function() {
	$("#begindate").addClass("Wate").bind("focus", function(){
   	 WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'});});
	 $("#enddate").addClass("Wate").bind("focus", function(){
	 WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'});});
	 //单位名称和分支机构名称不可修改
	 var id = $("#id").val();
	 if(""==id||null==id){
		 $("#orgId").attr("disabled",false);
		 $("#deptName").attr("disabled",false);
	 }
	 
	 $("#orgName").liveSearch({url:'${ctx}/project/sign/org/organization!signlist.action?typeId=5' + '&q='});
	 
	 $("#deptName").click(function(){
		    var orgName = $("#orgName").val();
			var orgCode = $("#orgCode").val();
			$("#dialog-confirm").dialog({
					resizable: false,
					height:140,
					title:"创建分支机构!",
					modal: true,
					Note:"ddddd",
					buttons: {
						"是": function() {
							var url ="${ctx}/project/sign/org/department!input.action?organizationId="+orgCode;
							var obj = new Object();
							mm = showDialogWindow(url);
							if(mm){
								if(mm.deptId){
									$("#branchOrgId").val(mm.deptId);
								}
								if(mm.depName){
									$("#deptName").val(mm.depName);
								}
							}
							$( this ).dialog( "close" );

						},
						"否": function() {
							var orgName = $("#orgName").val();
							var orgCode = $("#orgCode").val();
							$("#orgCode").val(orgCode);
							$("#deptName").val(orgName);
							$("#mark").val("0");
							$( this ).dialog( "close" );
						}
					}
			});
	 });
	 $("#inputForm").validate({
   			rules:{
   				orgName:{
   					required:true
   				},
   				orgId:{
					required:true
				},
				contractorder:{
   					required:true
   				},
   				deptName:{
   					required:true
   				},
   	   			contractCost:{
	   	   			required:true,
					number:true
   	   			}
   			},
   			messages:{
   				orgId:{
					required:"请选择有效的单位信息!"
				}
   			}
	});
});

function deletedesign(url){
	$.ajax({
		   type: "POST",
		   url: url,
		   success: function(msg){
			   if(msg=="1"){
				  alert("删除成功!");
				  window.returnValue=true;
				  window.close();
			   }else{
				  alert("删除失败!");
			   }
		   }
		});
}
function checkdraw(){
	var drawsign = $("input[name=drawIdList]:checked");
	var orgCode = $("#orgCode").val();
	if(!orgCode){
		alert("请选择单位!");
		return false;
	}else{
		return true;
	}
	return false;
}
function setValue(orgName , orgCode){
	$("#orgName").val(orgName);
	$("#orgCode").val(orgCode);
	$("#jquery-live-search").fadeOut();
	$("#deptName").focus();
}
function  addOrg(){
	$("#jquery-live-search").hide();
	 var  url="${ctx}/project/org/detectionorg!input.action?typeId=5";	
	 mm =showDialogWindow(url);
	 if(mm){
			if(mm.orgName){
				$("#orgName").val(mm.orgName);
			}
			if(mm.orgId){
				$("#orgCode").val(mm.orgId);
			}
		}
}

</script>
</head>
<body>
<form action="detectcontract!save.action" method="post" id="inputForm"
	class='yform'>
	<div id="caption">
<h6> <c:if test="${param.typeId == '3' }"> <th>中心实验室信息</th></c:if>
      <c:if test="${param.typeId == '4' }"> <th>工地实验室信息</th></c:if></h6>
</div>
<input type="hidden" name="signid" id="signid" value="${signid}" />
<table width="200" class="noborder">
<tr>
		<td>单位选择：</td>
		<td colspan="3"><c:if test="${empty id}">
			<input type="text" name="orgName" id="orgName"  />
			<input type="hidden" name="orgCode" id="orgCode"  />
		</c:if> <c:if test="${ not empty id }">
			<input type="text" name="orgName" id="orgName"
				value="<pt:labels type="org" argument1="${orgId }" single="true"></pt:labels>" disabled="disabled" />
			<input type="hidden" name="orgCode" id="orgCode" value="${orgId}" />
			<input type="hidden" name="orgId" id="orgId" value="${orgId}" />
		</c:if> <input type="hidden" name="id" id="id" value="${id}" />
		<div style="display: inline; color:orange " >
		</br></>输入单位名称关键字，查询对应单位;如果单位信息不存在,请选择【新增】。。</div>
		</td>
		</tr>
		<tr>
		<td>创建分支机构：</td>
		<td colspan="3"><input id="deptName" name="deptName" type="text"
			value="<pt:labels type="dept" argument1="${partid }" single="true"></pt:labels>" readonly="readonly"
			disabled="disabled" /> <input type="hidden" name="mark" id="mark" />
		<input type="hidden" id="branchOrgId" name="branchOrgId"
			value="${branchOrgCode.id}" /> <input type="hidden" name="projectId"
			value="${projectId}" /> <input type="hidden" name="contractKind"
			value="${contractKind}" />
		<c:if test="${empty id  }">
			<div style="display: inline; color:orange "></br>选择【是】,创建分支机构;选择【否】,单位名称与分支机构相同 </div>
		</c:if>
		<div id="dialog-confirm" title="Empty the recycle bin?" style="display: none;">
			<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>是否创建分支机构！</p>
		</div></td>
	</tr>

	<tr>
		<td><c:if test="${param.typeId == '3' }">中心实验室名称：</c:if>
     	 <c:if test="${param.typeId == '4' }">工地实验室名称：</c:if></td>
		<td colspan="3"><input id="contractorder" name="contractorder" type="text" value="${contractorder}" /></td>
	</tr>
	<tr>
		<td>实验室编号：</td>
		<td><input name="contractnum" type="text" value="${contractnum}" /></td>
	</tr>
	<tr>
		<td>开始时间：</td>
		<td><input id="begindate" name="begindate" type="text"
			value="${begindate}" /></td>
		<td>结束时间：</td>
		<td><input id="enddate" name="enddate" type="text"
			value="${enddate}" /></td>
	</tr>
	<tr>
		<td>电话：</td>
		<td><input id="phone" name="phone" type="text"
			value="${phone}"></input></td>
		<td>传真：</td>
		<td><input id="fax" name="fax" type="text"
			value="${fax}" /></td>
	</tr>
	<tr>
		<td>邮政编码：</td>
		<td><input name="postcode" type="text" value="${postcode}" /></td>
		<td>电子邮箱：</td>
		<td><input id="orgLevel" name="email" type="text"
			value="${email}" /></td>
	</tr>
	<tr>
		<td>持试验检测人员证书：</td>
		<td><input id="inspector" name="inspector" type="text"
			value="${inspector}" /></td>
		<td>持试验检测工程师证书人数：</td>
		<td><input id="engineer" name="engineer" type="text"
			value="${engineer}" /></td>
	</tr>
	<tr>

		<td>相关专业高级职称人数：</td>
		<td><input id="senior" name="senior" type="text"
			value="${senior}" /></td>
		<td>试验检测用房总面积（m2）：</td>
		<td><input id="floor" name="floor" type="text"
			value="${floor}" /></td>
	</tr>
	<tr>
	<td>工地试验室授权业务范围：</td>
		<td colspan="3"><input id="scope" name="scope" type="text"
			value="${scope}" /></td>
		
	</tr>
	<tr>
		<td>备注：</td>
		<td colspan="3"><textarea rows="" cols="" name="remark">${remark}</textarea>
		</td>
	</tr>
</table>

<div class="type-button"><input id="addSuper"  
	type="submit" class="submit" value="提交" onclick="return checkdraw();" />&nbsp;
	<c:if test="${fn:length(id)!=0}">
	<input id="colseWin" type="button" value="删除" class="reset"
		onclick="deletedesign('${ctx}/project/labs/detectcontract!delete.action?id=${id}&projectId=${projectId}&contractKind=${contractKind}')" />
	</c:if>
	<input
	  type="button" value="取消" class="reset"
	onclick="window.close();" />
	</div>
</form>
</body>
</html>
